import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 期初库存台账信息 */
export interface StoreInit {
  id: number // id
  customerAccount?: string // 客户账号
  customerName: string // 客户
  storeLocation: string // 仓库地点
  storeName: string // 仓库名称
  drawingNumber: string // 图号
  productName: string // 品名
  initAmount?: number // 期初数量
  currentAmount?: number // 当前库存
}

// 期初库存台账 API
export const StoreInitApi = {
  // 查询期初库存台账分页
  getStoreInitPage: async (params: any) => {
    return await request.get({ url: `/business/store-init/page`, params })
  },

  // 查询期初库存台账详情
  getStoreInit: async (id: number) => {
    return await request.get({ url: `/business/store-init/get?id=` + id })
  },

  // 新增期初库存台账
  createStoreInit: async (data: StoreInit) => {
    return await request.post({ url: `/business/store-init/create`, data })
  },

  // 修改期初库存台账
  updateStoreInit: async (data: StoreInit) => {
    return await request.put({ url: `/business/store-init/update`, data })
  },

  // 删除期初库存台账
  deleteStoreInit: async (id: number) => {
    return await request.delete({ url: `/business/store-init/delete?id=` + id })
  },

  /** 批量删除期初库存台账 */
  deleteStoreInitList: async (ids: number[]) => {
    return await request.delete({ url: `/business/store-init/delete-list?ids=${ids.join(',')}` })
  },

  // 导出期初库存台账 Excel
  exportStoreInit: async (params) => {
    return await request.download({ url: `/business/store-init/export-excel`, params })
  },

  // 下载导入模板
  importTemplate: async () => {
    return request.download({ url: '/business/store-init/get-import-template' })
  }
}
